package com.lanlian.uikit;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckedTextView;
import android.widget.LinearLayout;

import java.util.ArrayList;

/**
 * <pre>
 *     author : huxiaobo
 *     e-mail : huxiaobo@xlanlian.com
 *     date   : 2018/11/8 14:27
 *     desc   : todo
 *     version: 1.0
 * </pre>
 */
public class ResearchSelectAdapter extends BaseAdapter {

    private Context mContext;
    private ArrayList<String> mList;

    public boolean isMore() {
        return more;
    }

    public void setMore(boolean more) {
        this.more = more;
    }

    private boolean more;

    public ResearchSelectAdapter(Context mContext, ArrayList<String> mList) {
        this.mContext = mContext;
        this.mList = mList;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LinearLayout.inflate(mContext, R.layout.adapter_research_select, null);
            if (more) {
                convertView = LinearLayout.inflate(mContext, R.layout.adapter_research_select_more, null);
            }
        }
        CheckedTextView mCtItem = convertView.findViewById(R.id.tv_item);
        mCtItem.setText(mList.get(position));
        return convertView;
    }
}
